<!doctype html>

<html>
<head>
  <link rel="shortcut icon" href="static/images/favicon.ico" type="image/x-icon">
  <title>dom.js (Closure Library API Documentation - JavaScript)</title>
  <link rel="stylesheet" href="static/css/base.css">
  <link rel="stylesheet" href="static/css/doc.css">
  <link rel="stylesheet" href="static/css/sidetree.css">
  <link rel="stylesheet" href="static/css/prettify.css">

  <script>
     var _staticFilePath = "static/";
     var _typeTreeName = "goog";
     var _fileTreeName = "Source";
  </script>

  <script src="static/js/doc.js">
  </script>


  <meta charset="utf8">
</head>

<body onload="grokdoc.onLoad();">

<div id="header">
  <div class="g-section g-tpl-50-50 g-split">
    <div class="g-unit g-first">
      <a id="logo" href="index.html">Closure Library API Documentation</a>
    </div>

    <div class="g-unit">
      <div class="g-c">
        <strong>Go to class or file:</strong>
        <input type="text" id="ac">
      </div>
    </div>
  </div>
</div>

<div class="clear"></div>

<h2><a href="closure_goog_fx_dom.js.html">dom.js</a></h2>

<pre class="prettyprint lang-js">
<a name="line1"></a>// Copyright 2005 The Closure Library Authors. All Rights Reserved.
<a name="line2"></a>//
<a name="line3"></a>// Licensed under the Apache License, Version 2.0 (the &quot;License&quot;);
<a name="line4"></a>// you may not use this file except in compliance with the License.
<a name="line5"></a>// You may obtain a copy of the License at
<a name="line6"></a>//
<a name="line7"></a>//      http://www.apache.org/licenses/LICENSE-2.0
<a name="line8"></a>//
<a name="line9"></a>// Unless required by applicable law or agreed to in writing, software
<a name="line10"></a>// distributed under the License is distributed on an &quot;AS-IS&quot; BASIS,
<a name="line11"></a>// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
<a name="line12"></a>// See the License for the specific language governing permissions and
<a name="line13"></a>// limitations under the License.
<a name="line14"></a>
<a name="line15"></a>/**
<a name="line16"></a> * @fileoverview Predefined DHTML animations such as slide, resize and fade.
<a name="line17"></a> *
<a name="line18"></a> * @see ../demos/effects.html
<a name="line19"></a> */
<a name="line20"></a>
<a name="line21"></a>goog.provide(&#39;goog.fx.dom&#39;);
<a name="line22"></a>goog.provide(&#39;goog.fx.dom.BgColorTransform&#39;);
<a name="line23"></a>goog.provide(&#39;goog.fx.dom.ColorTransform&#39;);
<a name="line24"></a>goog.provide(&#39;goog.fx.dom.Fade&#39;);
<a name="line25"></a>goog.provide(&#39;goog.fx.dom.FadeIn&#39;);
<a name="line26"></a>goog.provide(&#39;goog.fx.dom.FadeInAndShow&#39;);
<a name="line27"></a>goog.provide(&#39;goog.fx.dom.FadeOut&#39;);
<a name="line28"></a>goog.provide(&#39;goog.fx.dom.FadeOutAndHide&#39;);
<a name="line29"></a>goog.provide(&#39;goog.fx.dom.PredefinedEffect&#39;);
<a name="line30"></a>goog.provide(&#39;goog.fx.dom.Resize&#39;);
<a name="line31"></a>goog.provide(&#39;goog.fx.dom.ResizeHeight&#39;);
<a name="line32"></a>goog.provide(&#39;goog.fx.dom.ResizeWidth&#39;);
<a name="line33"></a>goog.provide(&#39;goog.fx.dom.Scroll&#39;);
<a name="line34"></a>goog.provide(&#39;goog.fx.dom.Slide&#39;);
<a name="line35"></a>goog.provide(&#39;goog.fx.dom.SlideFrom&#39;);
<a name="line36"></a>goog.provide(&#39;goog.fx.dom.Swipe&#39;);
<a name="line37"></a>
<a name="line38"></a>goog.require(&#39;goog.color&#39;);
<a name="line39"></a>goog.require(&#39;goog.events&#39;);
<a name="line40"></a>goog.require(&#39;goog.fx.Animation&#39;);
<a name="line41"></a>goog.require(&#39;goog.fx.Transition.EventType&#39;);
<a name="line42"></a>goog.require(&#39;goog.style&#39;);
<a name="line43"></a>goog.require(&#39;goog.style.bidi&#39;);
<a name="line44"></a>
<a name="line45"></a>
<a name="line46"></a>
<a name="line47"></a>/**
<a name="line48"></a> * Abstract class that provides reusable functionality for predefined animations
<a name="line49"></a> * that manipulate a single DOM element
<a name="line50"></a> *
<a name="line51"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line52"></a> * @param {Array.&lt;number&gt;} start Array for start coordinates.
<a name="line53"></a> * @param {Array.&lt;number&gt;} end Array for end coordinates.
<a name="line54"></a> * @param {number} time Length of animation in milliseconds.
<a name="line55"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line56"></a> * @extends {goog.fx.Animation}
<a name="line57"></a> * @constructor
<a name="line58"></a> */
<a name="line59"></a>goog.fx.dom.PredefinedEffect = function(element, start, end, time, opt_acc) {
<a name="line60"></a>  goog.fx.Animation.call(this, start, end, time, opt_acc);
<a name="line61"></a>
<a name="line62"></a>  /**
<a name="line63"></a>   * DOM Node that will be used in the animation
<a name="line64"></a>   * @type {Element}
<a name="line65"></a>   */
<a name="line66"></a>  this.element = element;
<a name="line67"></a>
<a name="line68"></a>  /**
<a name="line69"></a>   * Whether the element is rendered right-to-left. We cache this here for
<a name="line70"></a>   * efficiency.
<a name="line71"></a>   * @type {boolean|undefined}
<a name="line72"></a>   * @private
<a name="line73"></a>   */
<a name="line74"></a>  this.rightToLeft_;
<a name="line75"></a>};
<a name="line76"></a>goog.inherits(goog.fx.dom.PredefinedEffect, goog.fx.Animation);
<a name="line77"></a>
<a name="line78"></a>
<a name="line79"></a>/**
<a name="line80"></a> * Called to update the style of the element.
<a name="line81"></a> * @protected
<a name="line82"></a> */
<a name="line83"></a>goog.fx.dom.PredefinedEffect.prototype.updateStyle = goog.nullFunction;
<a name="line84"></a>
<a name="line85"></a>
<a name="line86"></a>/**
<a name="line87"></a> * Whether the element is rendered right-to-left. We initialize this lazily.
<a name="line88"></a> * @type {boolean|undefined}
<a name="line89"></a> * @private
<a name="line90"></a> */
<a name="line91"></a>goog.fx.dom.PredefinedEffect.prototype.rightToLeft_;
<a name="line92"></a>
<a name="line93"></a>
<a name="line94"></a>/**
<a name="line95"></a> * Whether the DOM element being manipulated is rendered right-to-left.
<a name="line96"></a> * @return {boolean} True if the DOM element is rendered right-to-left, false
<a name="line97"></a> *     otherwise.
<a name="line98"></a> */
<a name="line99"></a>goog.fx.dom.PredefinedEffect.prototype.isRightToLeft = function() {
<a name="line100"></a>  if (!goog.isDef(this.rightToLeft_)) {
<a name="line101"></a>    this.rightToLeft_ = goog.style.isRightToLeft(this.element);
<a name="line102"></a>  }
<a name="line103"></a>  return this.rightToLeft_;
<a name="line104"></a>};
<a name="line105"></a>
<a name="line106"></a>
<a name="line107"></a>/** @override */
<a name="line108"></a>goog.fx.dom.PredefinedEffect.prototype.onAnimate = function() {
<a name="line109"></a>  this.updateStyle();
<a name="line110"></a>  goog.fx.dom.PredefinedEffect.superClass_.onAnimate.call(this);
<a name="line111"></a>};
<a name="line112"></a>
<a name="line113"></a>
<a name="line114"></a>/** @override */
<a name="line115"></a>goog.fx.dom.PredefinedEffect.prototype.onEnd = function() {
<a name="line116"></a>  this.updateStyle();
<a name="line117"></a>  goog.fx.dom.PredefinedEffect.superClass_.onEnd.call(this);
<a name="line118"></a>};
<a name="line119"></a>
<a name="line120"></a>
<a name="line121"></a>/** @override */
<a name="line122"></a>goog.fx.dom.PredefinedEffect.prototype.onBegin = function() {
<a name="line123"></a>  this.updateStyle();
<a name="line124"></a>  goog.fx.dom.PredefinedEffect.superClass_.onBegin.call(this);
<a name="line125"></a>};
<a name="line126"></a>
<a name="line127"></a>
<a name="line128"></a>
<a name="line129"></a>/**
<a name="line130"></a> * Creates an animation object that will slide an element from A to B.  (This
<a name="line131"></a> * in effect automatically sets up the onanimate event for an Animation object)
<a name="line132"></a> *
<a name="line133"></a> * Start and End should be 2 dimensional arrays
<a name="line134"></a> *
<a name="line135"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line136"></a> * @param {Array.&lt;number&gt;} start 2D array for start coordinates (X, Y).
<a name="line137"></a> * @param {Array.&lt;number&gt;} end 2D array for end coordinates (X, Y).
<a name="line138"></a> * @param {number} time Length of animation in milliseconds.
<a name="line139"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line140"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line141"></a> * @constructor
<a name="line142"></a> */
<a name="line143"></a>goog.fx.dom.Slide = function(element, start, end, time, opt_acc) {
<a name="line144"></a>  if (start.length != 2 || end.length != 2) {
<a name="line145"></a>    throw Error(&#39;Start and end points must be 2D&#39;);
<a name="line146"></a>  }
<a name="line147"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line148"></a>};
<a name="line149"></a>goog.inherits(goog.fx.dom.Slide, goog.fx.dom.PredefinedEffect);
<a name="line150"></a>
<a name="line151"></a>
<a name="line152"></a>/** @override */
<a name="line153"></a>goog.fx.dom.Slide.prototype.updateStyle = function() {
<a name="line154"></a>  var pos = (this.isRightPositioningForRtlEnabled() &amp;&amp; this.isRightToLeft()) ?
<a name="line155"></a>      &#39;right&#39; : &#39;left&#39;;
<a name="line156"></a>  this.element.style[pos] = Math.round(this.coords[0]) + &#39;px&#39;;
<a name="line157"></a>  this.element.style.top = Math.round(this.coords[1]) + &#39;px&#39;;
<a name="line158"></a>};
<a name="line159"></a>
<a name="line160"></a>
<a name="line161"></a>
<a name="line162"></a>/**
<a name="line163"></a> * Slides an element from its current position.
<a name="line164"></a> *
<a name="line165"></a> * @param {Element} element DOM node to be used in the animation.
<a name="line166"></a> * @param {Array.&lt;number&gt;} end 2D array for end coordinates (X, Y).
<a name="line167"></a> * @param {number} time Length of animation in milliseconds.
<a name="line168"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line169"></a> * @extends {goog.fx.dom.Slide}
<a name="line170"></a> * @constructor
<a name="line171"></a> */
<a name="line172"></a>goog.fx.dom.SlideFrom = function(element, end, time, opt_acc) {
<a name="line173"></a>  var offsetLeft = this.isRightPositioningForRtlEnabled() ?
<a name="line174"></a>      goog.style.bidi.getOffsetStart(element) : element.offsetLeft;
<a name="line175"></a>  var start = [offsetLeft, element.offsetTop];
<a name="line176"></a>  goog.fx.dom.Slide.call(this, element, start, end, time, opt_acc);
<a name="line177"></a>};
<a name="line178"></a>goog.inherits(goog.fx.dom.SlideFrom, goog.fx.dom.Slide);
<a name="line179"></a>
<a name="line180"></a>
<a name="line181"></a>/** @override */
<a name="line182"></a>goog.fx.dom.SlideFrom.prototype.onBegin = function() {
<a name="line183"></a>  var offsetLeft = this.isRightPositioningForRtlEnabled() ?
<a name="line184"></a>      goog.style.bidi.getOffsetStart(this.element) : this.element.offsetLeft;
<a name="line185"></a>  this.startPoint = [offsetLeft, this.element.offsetTop];
<a name="line186"></a>  goog.fx.dom.SlideFrom.superClass_.onBegin.call(this);
<a name="line187"></a>};
<a name="line188"></a>
<a name="line189"></a>
<a name="line190"></a>
<a name="line191"></a>/**
<a name="line192"></a> * Creates an animation object that will slide an element into its final size.
<a name="line193"></a> * Requires that the element is absolutely positioned.
<a name="line194"></a> *
<a name="line195"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line196"></a> * @param {Array.&lt;number&gt;} start 2D array for start size (W, H).
<a name="line197"></a> * @param {Array.&lt;number&gt;} end 2D array for end size (W, H).
<a name="line198"></a> * @param {number} time Length of animation in milliseconds.
<a name="line199"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line200"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line201"></a> * @constructor
<a name="line202"></a> */
<a name="line203"></a>goog.fx.dom.Swipe = function(element, start, end, time, opt_acc) {
<a name="line204"></a>  if (start.length != 2 || end.length != 2) {
<a name="line205"></a>    throw Error(&#39;Start and end points must be 2D&#39;);
<a name="line206"></a>  }
<a name="line207"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line208"></a>
<a name="line209"></a>  /*
<a name="line210"></a>   * Maximum width for element.
<a name="line211"></a>   * @type {number}
<a name="line212"></a>   * @private
<a name="line213"></a>   */
<a name="line214"></a>  this.maxWidth_ = Math.max(this.endPoint[0], this.startPoint[0]);
<a name="line215"></a>
<a name="line216"></a>  /*
<a name="line217"></a>   * Maximum height for element.
<a name="line218"></a>   * @type {number}
<a name="line219"></a>   * @private
<a name="line220"></a>   */
<a name="line221"></a>  this.maxHeight_ = Math.max(this.endPoint[1], this.startPoint[1]);
<a name="line222"></a>};
<a name="line223"></a>goog.inherits(goog.fx.dom.Swipe, goog.fx.dom.PredefinedEffect);
<a name="line224"></a>
<a name="line225"></a>
<a name="line226"></a>/**
<a name="line227"></a> * Animation event handler that will resize an element by setting its width,
<a name="line228"></a> * height and clipping.
<a name="line229"></a> * @protected
<a name="line230"></a> * @override
<a name="line231"></a> */
<a name="line232"></a>goog.fx.dom.Swipe.prototype.updateStyle = function() {
<a name="line233"></a>  var x = this.coords[0];
<a name="line234"></a>  var y = this.coords[1];
<a name="line235"></a>  this.clip_(Math.round(x), Math.round(y), this.maxWidth_, this.maxHeight_);
<a name="line236"></a>  this.element.style.width = Math.round(x) + &#39;px&#39;;
<a name="line237"></a>  var marginX = (this.isRightPositioningForRtlEnabled() &amp;&amp;
<a name="line238"></a>      this.isRightToLeft()) ? &#39;marginRight&#39; : &#39;marginLeft&#39;;
<a name="line239"></a>
<a name="line240"></a>  this.element.style[marginX] = Math.round(x) - this.maxWidth_ + &#39;px&#39;;
<a name="line241"></a>  this.element.style.marginTop = Math.round(y) - this.maxHeight_ + &#39;px&#39;;
<a name="line242"></a>};
<a name="line243"></a>
<a name="line244"></a>
<a name="line245"></a>/**
<a name="line246"></a> * Helper function for setting element clipping.
<a name="line247"></a> * @param {number} x Current element width.
<a name="line248"></a> * @param {number} y Current element height.
<a name="line249"></a> * @param {number} w Maximum element width.
<a name="line250"></a> * @param {number} h Maximum element height.
<a name="line251"></a> * @private
<a name="line252"></a> */
<a name="line253"></a>goog.fx.dom.Swipe.prototype.clip_ = function(x, y, w, h) {
<a name="line254"></a>  this.element.style.clip =
<a name="line255"></a>      &#39;rect(&#39; + (h - y) + &#39;px &#39; + w + &#39;px &#39; + h + &#39;px &#39; + (w - x) + &#39;px)&#39;;
<a name="line256"></a>};
<a name="line257"></a>
<a name="line258"></a>
<a name="line259"></a>
<a name="line260"></a>/**
<a name="line261"></a> * Creates an animation object that will scroll an element from A to B.
<a name="line262"></a> *
<a name="line263"></a> * Start and End should be 2 dimensional arrays
<a name="line264"></a> *
<a name="line265"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line266"></a> * @param {Array.&lt;number&gt;} start 2D array for start scroll left and top.
<a name="line267"></a> * @param {Array.&lt;number&gt;} end 2D array for end scroll left and top.
<a name="line268"></a> * @param {number} time Length of animation in milliseconds.
<a name="line269"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line270"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line271"></a> * @constructor
<a name="line272"></a> */
<a name="line273"></a>goog.fx.dom.Scroll = function(element, start, end, time, opt_acc) {
<a name="line274"></a>  if (start.length != 2 || end.length != 2) {
<a name="line275"></a>    throw Error(&#39;Start and end points must be 2D&#39;);
<a name="line276"></a>  }
<a name="line277"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line278"></a>};
<a name="line279"></a>goog.inherits(goog.fx.dom.Scroll, goog.fx.dom.PredefinedEffect);
<a name="line280"></a>
<a name="line281"></a>
<a name="line282"></a>/**
<a name="line283"></a> * Animation event handler that will set the scroll posiiton of an element
<a name="line284"></a> * @protected
<a name="line285"></a> * @override
<a name="line286"></a> */
<a name="line287"></a>goog.fx.dom.Scroll.prototype.updateStyle = function() {
<a name="line288"></a>  if (this.isRightPositioningForRtlEnabled()) {
<a name="line289"></a>    goog.style.bidi.setScrollOffset(this.element, Math.round(this.coords[0]));
<a name="line290"></a>  } else {
<a name="line291"></a>    this.element.scrollLeft = Math.round(this.coords[0]);
<a name="line292"></a>  }
<a name="line293"></a>  this.element.scrollTop = Math.round(this.coords[1]);
<a name="line294"></a>};
<a name="line295"></a>
<a name="line296"></a>
<a name="line297"></a>
<a name="line298"></a>/**
<a name="line299"></a> * Creates an animation object that will resize an element between two widths
<a name="line300"></a> * and heights.
<a name="line301"></a> *
<a name="line302"></a> * Start and End should be 2 dimensional arrays
<a name="line303"></a> *
<a name="line304"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line305"></a> * @param {Array.&lt;number&gt;} start 2D array for start width and height.
<a name="line306"></a> * @param {Array.&lt;number&gt;} end 2D array for end width and height.
<a name="line307"></a> * @param {number} time Length of animation in milliseconds.
<a name="line308"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line309"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line310"></a> * @constructor
<a name="line311"></a> */
<a name="line312"></a>goog.fx.dom.Resize = function(element, start, end, time, opt_acc) {
<a name="line313"></a>  if (start.length != 2 || end.length != 2) {
<a name="line314"></a>    throw Error(&#39;Start and end points must be 2D&#39;);
<a name="line315"></a>  }
<a name="line316"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line317"></a>};
<a name="line318"></a>goog.inherits(goog.fx.dom.Resize, goog.fx.dom.PredefinedEffect);
<a name="line319"></a>
<a name="line320"></a>
<a name="line321"></a>/**
<a name="line322"></a> * Animation event handler that will resize an element by setting its width and
<a name="line323"></a> * height.
<a name="line324"></a> * @protected
<a name="line325"></a> * @override
<a name="line326"></a> */
<a name="line327"></a>goog.fx.dom.Resize.prototype.updateStyle = function() {
<a name="line328"></a>  this.element.style.width = Math.round(this.coords[0]) + &#39;px&#39;;
<a name="line329"></a>  this.element.style.height = Math.round(this.coords[1]) + &#39;px&#39;;
<a name="line330"></a>};
<a name="line331"></a>
<a name="line332"></a>
<a name="line333"></a>
<a name="line334"></a>/**
<a name="line335"></a> * Creates an animation object that will resize an element between two widths
<a name="line336"></a> *
<a name="line337"></a> * Start and End should be numbers
<a name="line338"></a> *
<a name="line339"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line340"></a> * @param {number} start Start width.
<a name="line341"></a> * @param {number} end End width.
<a name="line342"></a> * @param {number} time Length of animation in milliseconds.
<a name="line343"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line344"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line345"></a> * @constructor
<a name="line346"></a> */
<a name="line347"></a>goog.fx.dom.ResizeWidth = function(element, start, end, time, opt_acc) {
<a name="line348"></a>  goog.fx.dom.PredefinedEffect.call(this, element, [start],
<a name="line349"></a>                                    [end], time, opt_acc);
<a name="line350"></a>};
<a name="line351"></a>goog.inherits(goog.fx.dom.ResizeWidth, goog.fx.dom.PredefinedEffect);
<a name="line352"></a>
<a name="line353"></a>
<a name="line354"></a>/**
<a name="line355"></a> * Animation event handler that will resize an element by setting its width.
<a name="line356"></a> * @protected
<a name="line357"></a> * @override
<a name="line358"></a> */
<a name="line359"></a>goog.fx.dom.ResizeWidth.prototype.updateStyle = function() {
<a name="line360"></a>  this.element.style.width = Math.round(this.coords[0]) + &#39;px&#39;;
<a name="line361"></a>};
<a name="line362"></a>
<a name="line363"></a>
<a name="line364"></a>
<a name="line365"></a>/**
<a name="line366"></a> * Creates an animation object that will resize an element between two heights
<a name="line367"></a> *
<a name="line368"></a> * Start and End should be numbers
<a name="line369"></a> *
<a name="line370"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line371"></a> * @param {number} start Start height.
<a name="line372"></a> * @param {number} end End height.
<a name="line373"></a> * @param {number} time Length of animation in milliseconds.
<a name="line374"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line375"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line376"></a> * @constructor
<a name="line377"></a> */
<a name="line378"></a>goog.fx.dom.ResizeHeight = function(element, start, end, time, opt_acc) {
<a name="line379"></a>  goog.fx.dom.PredefinedEffect.call(this, element, [start],
<a name="line380"></a>                                    [end], time, opt_acc);
<a name="line381"></a>};
<a name="line382"></a>goog.inherits(goog.fx.dom.ResizeHeight, goog.fx.dom.PredefinedEffect);
<a name="line383"></a>
<a name="line384"></a>
<a name="line385"></a>/**
<a name="line386"></a> * Animation event handler that will resize an element by setting its height.
<a name="line387"></a> * @protected
<a name="line388"></a> * @override
<a name="line389"></a> */
<a name="line390"></a>goog.fx.dom.ResizeHeight.prototype.updateStyle = function() {
<a name="line391"></a>  this.element.style.height = Math.round(this.coords[0]) + &#39;px&#39;;
<a name="line392"></a>};
<a name="line393"></a>
<a name="line394"></a>
<a name="line395"></a>
<a name="line396"></a>/**
<a name="line397"></a> * Creates an animation object that fades the opacity of an element between two
<a name="line398"></a> * limits.
<a name="line399"></a> *
<a name="line400"></a> * Start and End should be floats between 0 and 1
<a name="line401"></a> *
<a name="line402"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line403"></a> * @param {Array.&lt;number&gt;|number} start 1D Array or Number with start opacity.
<a name="line404"></a> * @param {Array.&lt;number&gt;|number} end 1D Array or Number for end opacity.
<a name="line405"></a> * @param {number} time Length of animation in milliseconds.
<a name="line406"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line407"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line408"></a> * @constructor
<a name="line409"></a> */
<a name="line410"></a>goog.fx.dom.Fade = function(element, start, end, time, opt_acc) {
<a name="line411"></a>  if (goog.isNumber(start)) start = [start];
<a name="line412"></a>  if (goog.isNumber(end)) end = [end];
<a name="line413"></a>
<a name="line414"></a>  goog.fx.dom.PredefinedEffect.call(this, element, start, end, time, opt_acc);
<a name="line415"></a>
<a name="line416"></a>  if (start.length != 1 || end.length != 1) {
<a name="line417"></a>    throw Error(&#39;Start and end points must be 1D&#39;);
<a name="line418"></a>  }
<a name="line419"></a>};
<a name="line420"></a>goog.inherits(goog.fx.dom.Fade, goog.fx.dom.PredefinedEffect);
<a name="line421"></a>
<a name="line422"></a>
<a name="line423"></a>/**
<a name="line424"></a> * Animation event handler that will set the opacity of an element.
<a name="line425"></a> * @protected
<a name="line426"></a> * @override
<a name="line427"></a> */
<a name="line428"></a>goog.fx.dom.Fade.prototype.updateStyle = function() {
<a name="line429"></a>  goog.style.setOpacity(this.element, this.coords[0]);
<a name="line430"></a>};
<a name="line431"></a>
<a name="line432"></a>
<a name="line433"></a>/**
<a name="line434"></a> * Animation event handler that will show the element.
<a name="line435"></a> */
<a name="line436"></a>goog.fx.dom.Fade.prototype.show = function() {
<a name="line437"></a>  this.element.style.display = &#39;&#39;;
<a name="line438"></a>};
<a name="line439"></a>
<a name="line440"></a>
<a name="line441"></a>/**
<a name="line442"></a> * Animation event handler that will hide the element
<a name="line443"></a> */
<a name="line444"></a>goog.fx.dom.Fade.prototype.hide = function() {
<a name="line445"></a>  this.element.style.display = &#39;none&#39;;
<a name="line446"></a>};
<a name="line447"></a>
<a name="line448"></a>
<a name="line449"></a>
<a name="line450"></a>/**
<a name="line451"></a> * Fades an element out from full opacity to completely transparent.
<a name="line452"></a> *
<a name="line453"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line454"></a> * @param {number} time Length of animation in milliseconds.
<a name="line455"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line456"></a> * @extends {goog.fx.dom.Fade}
<a name="line457"></a> * @constructor
<a name="line458"></a> */
<a name="line459"></a>goog.fx.dom.FadeOut = function(element, time, opt_acc) {
<a name="line460"></a>  goog.fx.dom.Fade.call(this, element, 1, 0, time, opt_acc);
<a name="line461"></a>};
<a name="line462"></a>goog.inherits(goog.fx.dom.FadeOut, goog.fx.dom.Fade);
<a name="line463"></a>
<a name="line464"></a>
<a name="line465"></a>
<a name="line466"></a>/**
<a name="line467"></a> * Fades an element in from completely transparent to fully opacity.
<a name="line468"></a> *
<a name="line469"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line470"></a> * @param {number} time Length of animation in milliseconds.
<a name="line471"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line472"></a> * @extends {goog.fx.dom.Fade}
<a name="line473"></a> * @constructor
<a name="line474"></a> */
<a name="line475"></a>goog.fx.dom.FadeIn = function(element, time, opt_acc) {
<a name="line476"></a>  goog.fx.dom.Fade.call(this, element, 0, 1, time, opt_acc);
<a name="line477"></a>};
<a name="line478"></a>goog.inherits(goog.fx.dom.FadeIn, goog.fx.dom.Fade);
<a name="line479"></a>
<a name="line480"></a>
<a name="line481"></a>
<a name="line482"></a>/**
<a name="line483"></a> * Fades an element out from full opacity to completely transparent and then
<a name="line484"></a> * sets the display to &#39;none&#39;
<a name="line485"></a> *
<a name="line486"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line487"></a> * @param {number} time Length of animation in milliseconds.
<a name="line488"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line489"></a> * @extends {goog.fx.dom.Fade}
<a name="line490"></a> * @constructor
<a name="line491"></a> */
<a name="line492"></a>goog.fx.dom.FadeOutAndHide = function(element, time, opt_acc) {
<a name="line493"></a>  goog.fx.dom.Fade.call(this, element, 1, 0, time, opt_acc);
<a name="line494"></a>};
<a name="line495"></a>goog.inherits(goog.fx.dom.FadeOutAndHide, goog.fx.dom.Fade);
<a name="line496"></a>
<a name="line497"></a>
<a name="line498"></a>/** @override */
<a name="line499"></a>goog.fx.dom.FadeOutAndHide.prototype.onBegin = function() {
<a name="line500"></a>  this.show();
<a name="line501"></a>  goog.fx.dom.FadeOutAndHide.superClass_.onBegin.call(this);
<a name="line502"></a>};
<a name="line503"></a>
<a name="line504"></a>
<a name="line505"></a>/** @override */
<a name="line506"></a>goog.fx.dom.FadeOutAndHide.prototype.onEnd = function() {
<a name="line507"></a>  this.hide();
<a name="line508"></a>  goog.fx.dom.FadeOutAndHide.superClass_.onEnd.call(this);
<a name="line509"></a>};
<a name="line510"></a>
<a name="line511"></a>
<a name="line512"></a>
<a name="line513"></a>/**
<a name="line514"></a> * Sets an element&#39;s display to be visible and then fades an element in from
<a name="line515"></a> * completely transparent to fully opacity
<a name="line516"></a> *
<a name="line517"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line518"></a> * @param {number} time Length of animation in milliseconds.
<a name="line519"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line520"></a> * @extends {goog.fx.dom.Fade}
<a name="line521"></a> * @constructor
<a name="line522"></a> */
<a name="line523"></a>goog.fx.dom.FadeInAndShow = function(element, time, opt_acc) {
<a name="line524"></a>  goog.fx.dom.Fade.call(this, element, 0, 1, time, opt_acc);
<a name="line525"></a>};
<a name="line526"></a>goog.inherits(goog.fx.dom.FadeInAndShow, goog.fx.dom.Fade);
<a name="line527"></a>
<a name="line528"></a>
<a name="line529"></a>/** @override */
<a name="line530"></a>goog.fx.dom.FadeInAndShow.prototype.onBegin = function() {
<a name="line531"></a>  this.show();
<a name="line532"></a>  goog.fx.dom.FadeInAndShow.superClass_.onBegin.call(this);
<a name="line533"></a>};
<a name="line534"></a>
<a name="line535"></a>
<a name="line536"></a>
<a name="line537"></a>/**
<a name="line538"></a> * Provides a transformation of an elements background-color.
<a name="line539"></a> *
<a name="line540"></a> * Start and End should be 3D arrays representing R,G,B
<a name="line541"></a> *
<a name="line542"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line543"></a> * @param {Array.&lt;number&gt;} start 3D Array for RGB of start color.
<a name="line544"></a> * @param {Array.&lt;number&gt;} end 3D Array for RGB of end color.
<a name="line545"></a> * @param {number} time Length of animation in milliseconds.
<a name="line546"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line547"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line548"></a> * @constructor
<a name="line549"></a> */
<a name="line550"></a>goog.fx.dom.BgColorTransform = function(element, start, end, time, opt_acc) {
<a name="line551"></a>  if (start.length != 3 || end.length != 3) {
<a name="line552"></a>    throw Error(&#39;Start and end points must be 3D&#39;);
<a name="line553"></a>  }
<a name="line554"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line555"></a>};
<a name="line556"></a>goog.inherits(goog.fx.dom.BgColorTransform, goog.fx.dom.PredefinedEffect);
<a name="line557"></a>
<a name="line558"></a>
<a name="line559"></a>/**
<a name="line560"></a> * Animation event handler that will set the background-color of an element
<a name="line561"></a> */
<a name="line562"></a>goog.fx.dom.BgColorTransform.prototype.setColor = function() {
<a name="line563"></a>  var coordsAsInts = [];
<a name="line564"></a>  for (var i = 0; i &lt; this.coords.length; i++) {
<a name="line565"></a>    coordsAsInts[i] = Math.round(this.coords[i]);
<a name="line566"></a>  }
<a name="line567"></a>  var color = &#39;rgb(&#39; + coordsAsInts.join(&#39;,&#39;) + &#39;)&#39;;
<a name="line568"></a>  this.element.style.backgroundColor = color;
<a name="line569"></a>};
<a name="line570"></a>
<a name="line571"></a>
<a name="line572"></a>/** @override */
<a name="line573"></a>goog.fx.dom.BgColorTransform.prototype.updateStyle = function() {
<a name="line574"></a>  this.setColor();
<a name="line575"></a>};
<a name="line576"></a>
<a name="line577"></a>
<a name="line578"></a>/**
<a name="line579"></a> * Fade elements background color from start color to the element&#39;s current
<a name="line580"></a> * background color.
<a name="line581"></a> *
<a name="line582"></a> * Start should be a 3D array representing R,G,B
<a name="line583"></a> *
<a name="line584"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line585"></a> * @param {Array.&lt;number&gt;} start 3D Array for RGB of start color.
<a name="line586"></a> * @param {number} time Length of animation in milliseconds.
<a name="line587"></a> * @param {goog.events.EventHandler=} opt_eventHandler Optional event handler
<a name="line588"></a> *     to use when listening for events.
<a name="line589"></a> */
<a name="line590"></a>goog.fx.dom.bgColorFadeIn = function(element, start, time, opt_eventHandler) {
<a name="line591"></a>  var initialBgColor = element.style.backgroundColor || &#39;&#39;;
<a name="line592"></a>  var computedBgColor = goog.style.getBackgroundColor(element);
<a name="line593"></a>  var end;
<a name="line594"></a>
<a name="line595"></a>  if (computedBgColor &amp;&amp; computedBgColor != &#39;transparent&#39; &amp;&amp;
<a name="line596"></a>      computedBgColor != &#39;rgba(0, 0, 0, 0)&#39;) {
<a name="line597"></a>    end = goog.color.hexToRgb(goog.color.parse(computedBgColor).hex);
<a name="line598"></a>  } else {
<a name="line599"></a>    end = [255, 255, 255];
<a name="line600"></a>  }
<a name="line601"></a>
<a name="line602"></a>  var anim = new goog.fx.dom.BgColorTransform(element, start, end, time);
<a name="line603"></a>
<a name="line604"></a>  function setBgColor() {
<a name="line605"></a>    element.style.backgroundColor = initialBgColor;
<a name="line606"></a>  }
<a name="line607"></a>
<a name="line608"></a>  if (opt_eventHandler) {
<a name="line609"></a>    opt_eventHandler.listen(
<a name="line610"></a>        anim, goog.fx.Transition.EventType.END, setBgColor);
<a name="line611"></a>  } else {
<a name="line612"></a>    goog.events.listen(
<a name="line613"></a>        anim, goog.fx.Transition.EventType.END, setBgColor);
<a name="line614"></a>  }
<a name="line615"></a>
<a name="line616"></a>  anim.play();
<a name="line617"></a>};
<a name="line618"></a>
<a name="line619"></a>
<a name="line620"></a>
<a name="line621"></a>/**
<a name="line622"></a> * Provides a transformation of an elements color.
<a name="line623"></a> *
<a name="line624"></a> * @param {Element} element Dom Node to be used in the animation.
<a name="line625"></a> * @param {Array.&lt;number&gt;} start 3D Array representing R,G,B.
<a name="line626"></a> * @param {Array.&lt;number&gt;} end 3D Array representing R,G,B.
<a name="line627"></a> * @param {number} time Length of animation in milliseconds.
<a name="line628"></a> * @param {Function=} opt_acc Acceleration function, returns 0-1 for inputs 0-1.
<a name="line629"></a> * @constructor
<a name="line630"></a> * @extends {goog.fx.dom.PredefinedEffect}
<a name="line631"></a> */
<a name="line632"></a>goog.fx.dom.ColorTransform = function(element, start, end, time, opt_acc) {
<a name="line633"></a>  if (start.length != 3 || end.length != 3) {
<a name="line634"></a>    throw Error(&#39;Start and end points must be 3D&#39;);
<a name="line635"></a>  }
<a name="line636"></a>  goog.fx.dom.PredefinedEffect.apply(this, arguments);
<a name="line637"></a>};
<a name="line638"></a>goog.inherits(goog.fx.dom.ColorTransform, goog.fx.dom.PredefinedEffect);
<a name="line639"></a>
<a name="line640"></a>
<a name="line641"></a>/**
<a name="line642"></a> * Animation event handler that will set the color of an element.
<a name="line643"></a> * @protected
<a name="line644"></a> * @override
<a name="line645"></a> */
<a name="line646"></a>goog.fx.dom.ColorTransform.prototype.updateStyle = function() {
<a name="line647"></a>  var coordsAsInts = [];
<a name="line648"></a>  for (var i = 0; i &lt; this.coords.length; i++) {
<a name="line649"></a>    coordsAsInts[i] = Math.round(this.coords[i]);
<a name="line650"></a>  }
<a name="line651"></a>  var color = &#39;rgb(&#39; + coordsAsInts.join(&#39;,&#39;) + &#39;)&#39;;
<a name="line652"></a>  this.element.style.color = color;
<a name="line653"></a>};
</pre>


</body>
</html>
